package net.lcheng.service.impl;

import net.lcheng.dao.SysRolePermissionsMapper;
import net.lcheng.model.SysRolePermissions;
import net.lcheng.model.SysRolePermissionsExample;
import net.lcheng.service.SysRolePermissionsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2016/8/29.
 */
@Service
public class SysRolePermissionsServiceImpl implements SysRolePermissionsService{
    @Resource
    private SysRolePermissionsMapper mapper;

    @Override
    public List<SysRolePermissions> getPermissionsByRoleIds(List<Integer> roleIdList) {
        if(roleIdList==null||roleIdList.size()==0) return null;
        SysRolePermissionsExample example = new SysRolePermissionsExample();
        example.or().andSysRoleIdIn(roleIdList);
        return mapper.selectByExample(example);
    }

    @Override
    public List<SysRolePermissions> getPermissionsByRoleId(int roleId) {
        SysRolePermissionsExample example = new SysRolePermissionsExample();
        example.or().andSysRoleIdEqualTo(roleId);
        return mapper.selectByExample(example);
    }
}
